<%- include('nav') %>
  <div class="text-sm breadcrumbs">
    <ul>
      <li>
        <a href="/admin/home">首页</a>
      </li>
      <li>群发任务</li>
    </ul>
  </div>

  <!-- <a href="/admin/home" class="my1 btn btn-sm btn-outline">返回</a> -->

  <div id="sends-app" style="min-width: 960px" class="col-12" data-theme="bumblebee">
    <table class="table col-12 table-zebra table-compact">
      <thead>
        <tr>
          <th>客户[邀请人]</th>
          <th>群发任务</th>
          <th>日期</th>
          <th>群</th>
          <th>群发类型</th>
        </tr>
      </thead>
      <tr v-for="send in sends">
        <td>
          <a target="_blank" v-bind:href="'/admin/manage?clientid='+send.clientid">
            <div class="flex items-center" v-if="send.user">
              <div class="pl1 badge badge-success badge-sm">{{send.user.nickname}}</div>
            </div>
            <div v-else class="badge badge-sm badge-info">{{send.clientid}}</div>
          </a>
        </td>
        <td>
          <div style="max-width: 200px">{{send.name}}</div>
        </td>
        <td>
          <div class="weui-form-preview__item" v-if="send.mode==2 && send.month!=1">
            <div class="weui-form-preview__label">发送周期:</div>
            <span>
              <span v-if="send.weekdays[1]">周一</span>
              <span v-if="send.weekdays[2]">周二</span>
              <span v-if="send.weekdays[3]">周三</span>
              <span v-if="send.weekdays[4]">周四</span>
              <span v-if="send.weekdays[5]">周五</span>
              <span v-if="send.weekdays[6]">周六</span>
              <span v-if="send.weekdays[0]">周日</span></span>
          </div>

          <div class="weui-form-preview__item" v-if="send.mode==2 && send.month==1">
            <div class="weui-form-preview__label">发送周期:</div>
            <span>每月{{send.days}}号</span>
          </div>

          <div class="weui-form-preview__item" v-if="send.mode==2">
            <div class="weui-form-preview__label">发送时间:</div>
            <span>{{send.daytime}} </span>
          </div>
        </td>
        <td>
          <span>
            <span v-for="topic in send.topics"> {{topic}} </span>
          </span>
        </td>
        <td>{{send.mode==2?'定期发送': '手动发送'}}</td>
      </tr>
    </table>

    <div v-if="sends.length==0" class="gray my2 center">
      <img src="/img/empty.png" style="width: 250px" class="mx-auto" />
      <div class="font-12 bold">没有更多数据了</div>
    </div>

    <div class="p1 font-12 gray center">到底了~</div>
  </div>

  <script>
    new Vue({
      el: "#sends-app",
      data: function () {
        return {
          sends: [],
        };
      },
      created: function () {
        this.fetchSends();
      },
      methods: {
        fetchSends: function () {
          var that = this;
          let loading = weui.loading();
          axios.get("/admin/bot/sends").then(function (res) {
            that.sends = res.data.sends;
            loading.hide();
          });
        },
      },
    });
  </script>